{
    //es5
    let regex = new RegExp('xyz', 'i')
    let regex2 = new RegExp(/xyz/i)
    console.log(regex.test('xyz123'), regex2.test('xyz123'))

    //es6
    let regex3 = new RegExp(/xyz/ig, 'i')
    console.log(regex3.flags)
}

{
    let s = 'bbb_bb_b';
    let a1 = /b+/g;
    let a2 = /b+/y;
    console.log('one', a1.exec(s), a2.exec(s));
    console.log('two', a1.exec(s), a2.exec(s));
    console.log(a1.sticky, a2.sticky);

}

{
    //\uD830\uDC2A当层两个字符
    console.log('u-1', /^\uD830/.test('\uD830\uDC2A'))
    //\uD830\uDC2A当成一个字符
    console.log('u-2', /^\uD830/u.test('\uD830\uDC2A'))
    //
    console.log(/\u{61}/.test('a'))
    //
    console.log(/\u{61}/u.test('a'))

    console.log(`\u{20BB7}`)

    let s = '𠮷'
    console.log('u-1', /^.$/.test(s))
    //如果字符串中的字符是大于两个字节的，一定要加u修饰符
    console.log('u-2', /^.$/u.test(s))

    console.log('test-1', /𠮷{2}/.test('𠮷𠮷'))
    console.log('test-2', /𠮷{2}/u.test('𠮷𠮷'))
}